package com.gui.mianshiya.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.gui.mianshiya.common.BaseResponse;
import com.gui.mianshiya.common.ResultUtils;
import com.gui.mianshiya.model.entity.QuestionAi;
import com.gui.mianshiya.service.AiQuestionService;
import com.gui.mianshiya.service.QuestionAiService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.Objects;

/**
 * @Title: AiQuestionController
 * @Author quit
 * @Package com.gui.mianshiya.controller
 * @Date 2025/4/28 19:58
 * @description:
 */

@RestController
@RequestMapping("/ai")
@Slf4j
public class AiQuestionController {

    @Resource
    private QuestionAiService  questionAiService;

    @GetMapping("/get")
    public BaseResponse<String> getAiQuestion(@RequestParam Long questionId, HttpServletRequest request) {
        LambdaQueryWrapper<QuestionAi> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(QuestionAi::getQuestionId,questionId);
        QuestionAi one = questionAiService.getOne(wrapper);
        if (one == null) {
            one = new QuestionAi();
            one.setContent("ai异常，该题目没有建议哟");
        }
        return ResultUtils.success(one.getContent());
    }
}
